# Contributor: Stone Tickle <lattis@mochiro.moe>
# Maintainer: Stone Tickle <lattis@mochiro.moe>
pkgname=muon
pkgver=0.3.0
pkgrel=0
pkgdesc="A meson-compatible build system."
url="https://muon.build"
arch="all"
license="GPL-3.0-only AND Apache-2.0"
depends="samurai"
makedepends="scdoc curl-dev libarchive-dev pkgconf-dev python3 py3-yaml linux-headers"
subpackages="$pkgname-doc"
source="
	$pkgname-v$pkgver.tar.gz::https://muon.build/releases/v$pkgver/muon-v$pkgver.tar.gz
	https://mochiro.moe/wrap/meson-docs-1.5.1-18-g587869c37.tar.gz
"
builddir="$srcdir/$pkgname-v$pkgver/"

build() {
	mv ../meson-docs subprojects/
	CFLAGS=-DBOOTSTRAP_NO_SAMU ./bootstrap.sh build
	build/muon setup build
	samu -C build

	# options copied from abuild-meson
	build/muon setup \
		-Dprefix=/usr \
		-Dlibdir=/usr/lib \
		-Dlibexecdir=/usr/libexec \
		-Dbindir=/usr/bin \
		-Dsbindir=/usr/sbin \
		-Dincludedir=/usr/include \
		-Ddatadir=/usr/share \
		-Dmandir=/usr/share/man \
		-Dinfodir=/usr/share/info \
		-Dlocaledir=/usr/share/locale \
		-Dsysconfdir=/etc \
		-Dlocalstatedir=/var \
		-Dsharedstatedir=/var/lib \
		-Dbuildtype=plain \
		-Dauto_features=auto \
		-Dwrap_mode=nodownload \
		-Db_lto=false \
		-Db_staticpic=true \
		-Db_pie=true \
		-Dsamurai=disabled \
		build

	samu -C build
}

check() {
	build/muon -C build test -j "${JOBS:-0}" -R -d dots
}

package() {
	DESTDIR=$pkgdir build/muon -C build install
}

sha512sums="
10d8d3d8d5df3898de22ed43fef234766e1884561d797a6462d614fd7be0f22eb7bbf40e096fe44d3e58f72e1fc631ef510f53a1e8ec36d4602ad7d5fe2771b3  muon-v0.3.0.tar.gz
0fca8a014251d56bc049558eab0a76bd7b50ed45f85aa6994607c85e4fe7caa77e980268a42346ef3c259daf9f0937a646156a667a4b3e8c50e90272cbc6e1b5  meson-docs-1.5.1-18-g587869c37.tar.gz
"
